<template>
  <div>
    <h2>Home组件内容</h2>
    <div>
      <ul class="nav nav-tabs">
        <li>
          <router-link
            class="list-group-item"
            active-class="active"
            ac
            to="/home/news"
            >News</router-link
          >
        </li>
        <li>
          <router-link
            class="list-group-item"
            active-class="active"
            to="/home/messages"
            >Message</router-link
          >
        </li>
      </ul>
      <keep-alive include="News"
        ><!-- 如果keep-alive 什么都不写，就代表此处展示的所有组件都保持活跃，切换时不会进行销毁
        include="News" 表示只有此处展示News组件才能保持活跃，切换时不会进行销毁
        include里面是组件的name
        include写多个组件的方式  1：直接用逗号分隔 “News，Message” 2：用v-bind绑定include，然后写成数组形式:include="['News','Message']"-->
        <router-view></router-view>
      </keep-alive>
    </div>
  </div>
</template>

<script>
export default {
  name: "Home",
  mounted() {
    console.log("Home组件挂载完毕");
  },
  beforeDestroy() {
    console.log("Home的VC", this);
    console.log("home组件即将被销毁了");
  },
};
</script>

<style>
</style>